package com.xiaoran.robot.customHandler;

import com.xiaoran.robot.entity.SenderInfo;
import com.xiaoran.robot.utils.MessageParser;
import com.xiaoran.robot.utils.RstMsgUtils;
import org.jsoup.Jsoup;

import java.io.IOException;
import java.util.ArrayList;

public class Praise {
    public ArrayList<Object> result() {
        MessageParser instance = MessageParser.getInstance();
        SenderInfo senderInfo = instance.senderInfo();
        String qq = senderInfo.getQid();

        RstMsgUtils rstMsg = new RstMsgUtils();
        if(senderInfo.getType().equals("GroupMessage")){
            rstMsg.atQQ(qq).addText("\n");
        }
        return rstMsg
                .addText(getPraise()).build();
    }

    private String getPraise(){
        String text = "";
        try {
           text = Jsoup.connect("https://chp.shadiao.app/api.php").ignoreContentType(true)
                    .get().body().text();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return text;
    }
}
